# aem.two_d.transient.step_linesink -- 
#
# Copyright (c) 2001, Willem Jan Zaadnoordijk

from types import *

from misc.fun_trans_elem import wpp1, slp1, slq1

import geometry
XY = geometry.XY

import base

import aem.container
RowList = aem.container.RowList
ColumnList = aem.container.ColumnList

class UnitStepLineSink(base.Element):
	'''Class for transient step linesinks to be used as child of (Head)LineSink

	The element is located at the segment from (-halflength,0) to (halflength,0)

	Python call: LineSink(halflength,t,parent)

	Attributes:

	  - halflength: half the length of the line (from Line)
	  - t: starting time
	  - parent: parent of the element (inherited from Element)
	  - parameters: dummy ColumnList [1] so that the contribution functions
	                                     do not need to be overloaded

	Overloaded functions from Element: __init__, potentialInfluence, dischargeInfluence'''
	
	def __init__(self,halflength=1,t=0,parent=None):
		# Call base class constructors
		self.t = t
		base.Element.__init__(self,parent)
		self.parameters = ColumnList([])
		self.halflength=halflength

	def __repr__(self):
		# Parent not yet included
		return 'UnitStepLineSink(t=' + str(self.t) +')'

	def potentialInfluence(self,xyw,t):
		assert isinstance(xyw,XY),"XY point is required"
		z = complex (xyw.x, xyw.y)
		rt = t-self.t
		rp = 1 / self.parent.alpha # RP=porosity/(hydaulic conductivity*average head
		return RowList( [ slp1(self.halflength, z, rt, rp) ] )

	def dischargeInfluence(self,xyw,t):
		assert isinstance(xyw,XY),"XY point is required"
		z = complex (xyw.x, xyw.y)
		rt = t-self.t
		rp = 1 / self.parent.alpha # RP=porosity/(hydaulic conductivity*average head
		return RowList( [ slq1(self.halflength, z, rt, rp) ] )
